package com.zhangpeng520.reAttend.controller;

import com.zhangpeng520.reAttend.Service.ReAttendService;
import com.zhangpeng520.reAttend.entity.ReAttend;
import com.zhangpeng520.user.entity.User;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/8/20 0020.
 */

@Controller
@RequestMapping("reAttend")
public class ReAttendController {


    @Autowired
    ReAttendService reAttendService;



    @RequestMapping()
    public String reAttend(ModelMap map, HttpSession session)
    {

        User user = (User)session.getAttribute("loginInfo");
        List<ReAttend> reAttendList = reAttendService.listTasks(user.getUsername());
        map.addAttribute("reAttend",reAttendList);
        return "reAttend";
    }

    @RequestMapping("/reAttendStart")
    public void reAttendStart(@RequestBody ReAttend reAttend)
    {

        reAttendService.startReAttendflow(reAttend);
    }

    @ResponseBody
    @RequestMapping("/reAttendList")
    public void reAttendList(String username)
    {
        reAttendService.listTasks(username);
    }



    @RequestMapping("/approve/")
    public void approve(ReAttend reAttend)
    {
        reAttendService.approve(reAttend);

    }
}
